package thread;

public class ThreadDemo16 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            for (int i = 0; i < 5; i++) {
                System.out.println("线程正在运行中");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }

            }
        });
        //线程启动之前,这个状态就是new状态,只有处于new状态才能调用start()
        System.out.println(t.getState());
        t.start();
        Thread.sleep(500);
        System.out.println(t.getState());
        t.join();
        //线程运行完毕后,状态就是terminated
        System.out.println(t.getState());


    }
}
